package com.cloud.bssp.gateway.handler;

import com.cloud.bssp.gateway.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * description: 全局异常捕获
 *
 * @author: weirx
 * @time: 2021/3/24 10:03
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public R errorHandler(Exception e) {
        log.info("[GlobalExceptionHandler]捕获全局异常，msg = {}", e);
        return R.failed(e.getMessage());
    }
}